package com.uploadtest.jiaotizhixing;

import java.util.concurrent.locks.LockSupport;
 
public class LockSupportTest {
    static Thread t1, t2 = null;
 
    public static void main(String[] args) {
        final char arrayA[] = "1234567".toCharArray();
        final char arrayB[] = "ABCDEFG".toCharArray();
        t1 = new Thread(() -> {
            for (char charA : arrayA) {
                System.out.print(charA);
                LockSupport.unpark(t2);
                LockSupport.park();
            }
        }, "t1");
        t1.start();
 
        t2 = new Thread(() -> {
            for (char charB : arrayB) {
                LockSupport.park();
                System.out.print(charB);
                LockSupport.unpark(t1);
 
            }
        }, "t2");
        t2.start();
    }
}